//
//  ActionPickerViewController.m
//  LoGD
//
//  Created by Thiago on 06/07/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "ActionPickerViewController.h"


@implementation ActionPickerViewController
@synthesize actionPicker;
@synthesize pickerData;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}

-(IBAction)buttonPressed{
	NSInteger row = [actionPicker selectedRowInComponent:0];
	NSString *selected = [pickerData objectAtIndex:row];
	NSString *title = [[NSString alloc] initWithFormat:@"You selected %@", selected];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
													message:@"Thanks for choosing."
												   delegate:nil
										  cancelButtonTitle:@"You're welcome."
										  otherButtonTitles:nil];
    [alert show];
	
	//Call new page in web view
	
	[alert release];
	[title release];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	NSArray *array = [[NSArray alloc] initWithObjects:@"Forest", @"Slay Other Players", @"Quit To The Fields", @"Mercenary Camp", nil];
	self.pickerData = array;
	
    [array release];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[actionPicker release];
	[pickerData release];
    [super dealloc];
}

#pragma mark -
#pragma mark Picker Data Source Methods
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
	return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component {
	
	return [pickerData count];	
}

#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView
				titleForRow:(NSInteger)row
				forComponent:(NSInteger)component {
	return [pickerData objectAtIndex:row];
}


@end
